;
; THIS PROGRAM PROGRAMS PROMS ON THE OPTIMAL TECHNOLOGY EP-2A
; PROM PROGRAMMER, USING OASIS ABSOLUTE FILES AS THE SOURCE.
; ALL PROGRAMS MUST BE ORG'D ON A PAGE BOUNDRY (ADDRESS = XX00)
; IF A PROGRAM DOESNT FILL PROM REMAINDER IS LEFT IN ERASED STATE.
;
; THE INTERFACE IS A SPECIAL CARD USING AN 8212 PIO. 
; CONTROL BITS ARE GENERATED USING A 74259 ADDRESSABLE LATCH
; B0 = CLOCK, B1 = RESET, B2 = CS*, B3 = VP.
;       31H     DATA PORT    PROGRAMMER DATA PORT
;       30H     CONTROL PORT
;	
	EXTRN	LINEIN		;LINE INPUT SUBROUTINE
DATA:	EQU	31H		;DATA PORT
CONT:	EQU	30H		;CONTROL PORT
RESET:	EQU	0		;CLOCK COMMAND
CS:	EQU	1		;SELECT COMMAND
VP:	EQU	3		;PROGRAM PULSE COMMAND
SET:	EQU	10H		;MODIFY COMMAND TO SET BIT, NOT CLEAR
CLR:	EQU	0FH		;MODIFY COMMAND TO CLEAR BIT
;
;***************************************************************************
; ON ENTRY INITIALIZE PROGRAMMER
;***************************************************************************
;
PROMPROG:
	  LD	A,CLOCK		;CLOCK BIT
	  OUT 	(CONT),A	;RESET CLOCK BIT
	  LD 	A,RESET		;RESET BIT
	  CALL 	PULSE
	  LD 	A,CS		;CHIP SELECT
	  OUT 	(CONT),A	;SET FOR READ PROM
	  LD 	A,VP		;PROGRAM PULSE
	  OUT	(CONT),A	;CLEAR VP
;
;***************************************************************************
; CLEAR THE SCREEN AND FIND OUT TYPE OF PROM BEING USED
;***************************************************************************
;
PTYPE:
	LD	DE,MSG1		;DISPLAY TYPES OF PROMS
	SC	2					;CHANGE THIS
	LD 	B,1		;NO OF CHAR TO ACCEPT
	LD	BE,PROM		;PROM TYPE
	LD	A,20H		;BLANK TYPE
	LD	(DE),A
	CALL	LINEIN		;GET TYPE
	JR	C,PTYPE		;ABNORMAL RETURN
	LD	A,(PROM)	;CHECK FOR VALID TYPE AND CONVERT FROM ASCII
	SUB	31H		;0-6 RANGE
	JP	C,PTYPE		;NOT NUMERIC
	CP 	7		;SEE IF TOO BIG
	JP	NC,PTYPE
	LD	(PROM),A	;STORE
;
;***************************************************************************
; DISPLAY TYPE AND COMMAND CODES
;***************************************************************************
;
	LD	DE,MSG2		;PROM TYPE
	SC	2					;CHANGE THIS
	LD	D,0		;CREATE INDEX INTO PROM TYPE TABLE
	LD	HL,MSG3		;BASE
	LD	A,(PROM)	;PROM TYPE
	LD	B,A		;SAVE COPY
	SLA	A		;
	SLA	A		;
	SLA	A		;
	LD	E,A		;MOVE TO HL
	ADD	HL,DE		;BASE PLUS OFFSET
	LD	E,B		;ADD ONE MORE
	ADD	HL,DE		;NOW BASE + 9*(PROM.TYPE-1)
	EX	DE,HL		;READY FOR SYSTEM CALL
	SC	2					;CHANGE THIS
	LD	DE,MSG4		;DISPLAY COMMANDS
	SC	2					;CHANGE THIS
;
; COMPUTE PROM SIZE
;
	LD	A,(PROM)	;GET PROM TYPE
	LD	B,A		;SAVE IT
	SLA	A		;MULTIPLY BY 3
	ADD	B		;
	LD	E,A		;MAKE 16 BIT
	LD	D,0		;
	LD	HL,PARAM	;PARAMETER TABLE START
	ADD	HL,DE		;POINTER
	LD	A,(HL)		;GET SIZE
	LD	(SIZE+1),A	;STORE FOR RETRIEVAL
;
; GET PROGRAM PARAMETERS
;
	INC	HL		;POINT TO LOOP COUNT
	LD	A,(HL)		;
	LD	(LOOPCNT),A	;STORE
	INC	HL		;POINT TO DELAY COUNT
	LD	A,(HL)		;
	LD	(DELCNT),A	;STORE
;
;***************************************************************************
; GET COMMAND
;***************************************************************************
;
CMD:
	LD	HL,IBUF		;CLEAR INPUT BUFFER
	LD	BC,8		;
	CALL	CLEAR		;CLEAR BUFFER
	LD	DE,MSG5		;DISPLAY COMMAND REQUEST
	SC	2					;CHANGE THIS
	LD	DE,IBUF		;INPUT BUFFER
	LD	B,1		;ONE CHAR ONLY
	CALL	LINEIN		;
        JR	C,CMD		;ABNORMAL RETURN
	LD	DE,IBUF		;GET COMMAND CHAR
	LD	A,(DE)		;
	CP	'E'		;ERASE?
	JP	Z,ERASE
	CP	'P'		;PROGRAM?
	JP	Z,PROG
	CP	'V'		;VERIFY?
	JP	Z,VERIFY
	CP	'W'		;WRITE FILE?
	JP	Z,WRITE
	CP	'L'		;LOAD?
	JP	Z,LOAD
	CP	'R'		;READ?
	JP	Z,READ
	CP	'A'		;ALTER?
	JP	Z,ALTER
	CP	'D'		;DUMP?
	JP	Z,DUMP
	CP	'T'		;NEW TYPE?
	JP	Z,PTYPE
	CP	'C'		;CLEAR BUFFER?
	JP	Z,CLRBUF
	JP	CMD		;INVALID RESPONSE
;
;***************************************************************************
; ERASE CHECK
;***************************************************************************
;
ERASE:
	LD	A,CS		;IN READ MODE
	OUT	(CONT),A
	LD	A,RESET		;RESET TO ADDRESS 0000
	CALL	PULSE
	LD	BC,(SIZE)	;GET PROM SIZE
	LD	HL,0		;CURRENT SIZE
.CHK:
	IN	A,(DATA)	;READ LOC
	CP	0FFH		;ERASED?
	CALL	NZ,.BAD		;NO
	CPI			;DEC BC, INC HL
	JP	PO,CMD		;DONE
	LD	A,CLOCK		;INCREMENT PROM ADDRESS
	CALL	PULSE		;
	JP	.CHK		;LOOP
.BAD:
	LD	D,0FFH		;ERASE CHECK CHAR
	CALL	BAD		;PRINT BAD DATA
	RET	C		;NO KEYBOARD INTERRUPT, CONTINUE
	POP	DE		;CLEAR RETURN OFF STACK
	JP	CMD		;
BAD:
	PUSH	BC		;SAVE REGS
	PUSH	AF
	PUSH	DE
	LD	DE,IBUF		;USE IBUF FOR OUTPUT BUFFER
	LD	B,H		;CONVERT TO HEX
	SC	16					;CHANGE THIS
	LD	B,L
	SC	16					;CHANGE THIS
	LD	A,20H		;SPACE CHAR
	LD	(DE),A		;
	INC	DE
	POP	BC		;GET CORRECT VALUE
	SC	16					;CHANGE THIS
	LD	A,20H		;SPACE
	LD	(DE),A
	INC	DE
	POP	BC		;GET PROM VALUE
	SC	16					;CHANGE THIS
	LD	A,0DH		;CRLF
	LD	(DE),A
	LD	DE,IBUF		;OUTPUT MESSAGE
	SC	2					;CHANGE THIS
	POP	BC		;RESTORE REG
	SC	3		;CHECK FOR CONSOLE INTERUPT   CHANGE THIS
	SCF			;CARRY SET IF NO KEYBOARD INTERUPT
	RET	Z		;NO INTERRUPT
	SC	4		;CLEAR KEYBOARD		;CHANGE THIS
	SCF			;RESET CARRY FLAG
	CCF
	RET			;RETURN WITH CARRY RESET

;***************************************************************************
; PROGRAM PROM
;***************************************************************************

PROG:
	LD	BC,(CLOCK)	;SETUP INITIAL PARAMETERS
	LD	HL,BUFFER
	LD	DE,(LOOPCNT)	;LOOP COUNT AND DELAY COUNT
	LD	A,RESET
	CALL	PULSE
	LD	A,CS		;SET PROM FOR WRITE
	OR	SET
	OUT	(CONT),A
.LOOP1:
	LD	A,(HL)		;OUTPUT CHAR TO PROM
	OUT	(DATA),A
	LD	A,VP		;PROGRAM PULSE
	OR	SET
	OUT	(CONT),A	;
	CALL	DELAY		;WAIT FOR PULSE TIME
	AND	CLR
	OUT	(CONT),A	;RESET PROGRAM PULSE
	LD	A,CLOCK		;INCREMENT PROM ADDR
	CALL	PULSE
	CPI			;DEC BC, INC HL
	JP	PE,.LOOP1	;CONTINUE UNTIL ONE LOOP FINISHED
	LD	BC,(SIZE)	;REROM CONTENTS

	LD	HL,BUFFER
	DEC	E		;DECREMENT LOOP COUNT
	JR	NZ,.LOOP1	;DO PROPER NUMBER OF LOOPS
	LD	A,CS
	OUT	(CONT),A	;RESET PROM PROG FOR READ
	LD	A,RESET
	CALL	PULSE
        JP	VERIFY		;VERIFY AFTER PROGRAMMING
DELAY:
	PUSH	BC		;TEMP SAVE
	PUSH	DE		;SAVE NUMBER OF DELAYS AND LOOP COUNT
.DEL1:
	CALL	.DEL2
	DEC	D		;COUNT LOOPS
	JR	NZ,.DEL1	;CONTINUE FOR CORRECT NUMBER OF LOOPS
	POP	DE		;RESTORE NUMBER OF DELAYS AND LOOP COUNT
        POP	BC		;RESTORE REG
	RET
.DEL2:				;DELAY .75 MS
	LD	C,185		;MINOR DELAY LOOP
.DEL3:
	DEC	C
	JR	NZ,.DEL3	;LOOP FOR .75 MS
	RET

;**************************************************************************
; VERIFY PROM CONTENTS
;**************************************************************************

VERIFY:
	LD	A,RESET		;RESET ADDRESS COUNTER
	CALL	PULSE
	LD	BC,(SIZE)	;GET PARAMETERS
	LD	HL,BUFFER
.LOOP:
	IN	A,(DATA)	;READ PROM
	CP	(HL)		;COMPARE WITH BUFFER
	CALL	NZ,.BAD		;PRINT RESULTS IF BAD COMPARE
	CPI			;INCRTMENT POINTERS
	JP	PO,CMD		;DONE ?
	LD	A,CLOCK		;ADVANCE PROM COUNTERS
	CALL	PULSE		;
	JP	.LOOP		;LOOP UNTIL FINISHED
.BAD:
	LD	D,(HL)		;SAVE CORRECT VALUE
	PUSH	HL		;SAVE BUFFER POINTER
	PUSH	DE		;AND VALUE
	LD	DE,BUFFER	;MAKE BUFFER POINTER REL ZERO FOR PRINT
	SCF			;CLEAR CARRY
	CCF
	SBC	HL,DE
	POP	DE		;RESTORE DE
	CALL	BAD		;PRINT VALUES
	POP	HL		;RESOTER BUFFER POINTER
	RET	C		;RETURN IF NO KEYBOARD INTERRUPT
	POP	DE		;THROW AWAY RETURN ADDR
	RET

;***************************************************************************
; GET FILE NAME
;***************************************************************************

FILE:
	LD	HL,DCB		;SETUP THE DIRECTORY CONTROL BLOCK
	LD	BC,17		;17 CHAR LONG
	CALL	CLEAR		;CLEAR DCB
	LD	DE,MSG6		;REQUEST FILENAME
	SC	2					;CHANGE THIS
	LD	B,8		;MAX NAME LENGTH
	LD	DE,DCB+1	;FILENAME AREA OF DCB
	CALL	LINEIN		;INPUT A LINE
	JP	C,CMD		;ABNORMAL RETURN
	LD	DE,MSG7		;GET FILE TYPE
	SC	2					;CHANGE THIS
	LD	DE,DCB+9	;DCB LOCATION FOR TYPE
	LD	B,8		;
	CALL	LINEIN
	JP	C,CMD		;ABNORMAL EXIT
.GETDRV:
	LD	DE,MSG8		;DISPLAY DRIVE REQUEST
	SC	2					;CHANGE THIS
	LD	DE,DCB		;GET DRIVE
	LD	B,1
	CALL	LINEIN
	JP	C,CMD		;ABNORMAL RETURN
	LD	A,C		;SEE IF ANY INPUT
	OR	A
	JR	Z,.ALL		;SEARCH ALL DRIVES
	LD	A,(DE)
	LD	B,A
	JR	.CONVERT
.ALL:
	LD	B,0FFH		;ALL DRIVES
.CONVERT:
	SC	25		;CONVERT TO LOGICAL CODE	CHANGE THIS
	JR	C,.GETDRV	;CONVERSION ERROR - TRY AGAIN
	LD	(DE),A		;STORE VALUE
	LD	HL,WORK		;WORK AREA
	SC	20		;LOOKUP DIRECTORY		CHANGE THIS
	JP	NZ,NOFIND	;CANT FIND FILE
	LD	A,2		;IS FILE ABSOLUTE ?
	CP	(HL)
	JR	Z,.AOK		;ABSOLUTE FILE - OK
	LD	DE,MSG11
	SC	2		;OUTPUT ERROR MESSAGE		CHANGE THIS
	JP	CMD
.AOK:
	LD	DE,DCB		;STORE DRIVE CODE
	LD	A,B
	LD	(DE),A
	PUSH	HL		;MOVE TO IX FOR INDEXING
	POP	IX
	LD	HL,FILEADDR	;GET START ADDRESS FOR FILE
	LD	A,(IX+1EH)	;LSB
	OR	A		;IS IT ZERO ?
	JR	Z,.BOK		;YES - OK
	LD	DE,MSG12	;ERROR MESSAGE
	SC	2						;CHANGE THIS
	JP	CMD		;GET NEW COMMAND
.BOK:
	LD	A,(IX+1FH)	;MSB
	LD	(HL),A		;STORE
	INC	HL		;MOVE TO FILE SECTOR ADDRESS
	LD	A,(IX+15H)
	LD	(HL),A		;SECTOR ADDRESS LSB
	INC	HL
	LD	A,(IX+16H)
	LD	(HL),A		;SECTOR ADDRESS MSB
	INC	HL		;MOVE TO FILE SECTOR COUNT
	LD	A,(IX+11H)
	LD	(HL),A		;SECTOR COUNT LSB
	INC	HL
	LD	A,(IX+12H)
	LD	(HL),A		;SECTOR COUNT MSB
	INC	HL
	LD	(HL),1		;SET FLAG FOR FILE DATA LOADED
	JP	CMD

;***************************************************************************
; LOAD BUFFER FROM DISK
;***************************************************************************

LOAD:
	LD	A,(FILESEL)	;HAS FILE BEEN DEFINED
	OR	A
	JR	NZ,.OK
	LD	DE,MSG12
	SC	2						;CHANGE THIS
	JP	CMD

.OK:
	LD	DE,MSG9		;REQUEST LOAD ADDRESS
	SC	2						;CHANGE THIS
	LD	B,2		;GET ADDRESS (2 CHARACTERS)
	LD	DE,LOADADDR
	LD	HL,LOADADDR	;CLEAR LINE
	LD	(HL),20H
	INC	HL
	LD	(HL),20H
	CALL	LINEIN
	JP	C,CMD
	LD	DE,LOADADDR	;CONVERT TO BINARY
	SC	14						;CHANGE THIS
	LD	A,L
	LD	HL,FILEADDR
	SUB	(HL)		;MAKE SURE IT IS IN RANGE
	JR	NC,.ROK		;RANGE OK
	LD	DE,MSG13	;OUTPUT ERROR MESSAGE
	SC	2						;CHANGE THIS
	LD	DE,LOADADDR
	LD	A,(DE)
	LD	C,A
	SC	5	;OUTPUT LOAD ADDR			;CHANGE THIS
	INC	DE
	LD	A,(DE)
	LD	C,A
	SC	5						;CHANGE THIS
	LD	DE,MSG14	;CONTINUE MESSAGE
	SC	2						;CHANGE THIS
	LD	HL,FILESEC	;GET PROG START ADDRESS
	LD	B,(HL)
	DEC	DE		;MOVE BACK TO START OF LOADADDR
	SC	16		;USE LOADADDR TO STORE START ADDR
	DEC	DE		;MOVE BACK TO START 
	DEC	DE		;
	LD	C,A		;
	SC	5						;CHANGE THIS
	INC	DE
	LD	A,(DE)
	LD	C,A
	SC	5						;CHANGE THIS
	SC	18		;CRLF				;CHANGE THIS
	JP	CMD		;START OVER
.ROK:
	LD	E,A		;SAVE START DIFFERANCE
	LD	A,(FILECNT)
	SUB	E		;FIND NUMBER IF SECTORS TO TRANSFER
	JR	NC,.ROK1	;FILE IS LONG ENOUGH
	LD	DE,MSG15
	SC	2						;CHANGE THIS
	JP	CMD
.ROK1:
	LD	C,A		;SAVE TRANSFER COUNT 
	LD	HL,(FILESEC)	;GET SECTOR ADDRESS
	LD	D,0
	LD	B,0
	ADD	HL,DE		;SECTOR TO START TRANSFER ON
	EX	HL,DE		;SETUP FOR DISK READ
	LD	HL,BUFFER
	LD	A,(SIZE+1)	;PROM SIZE IN PAGES
	CP	C		;WHICH IS SHORTER?
	JR	C,.FULL		;WILL FILL PROM
	PUSH	BC		;SAVE COUNT
	SUB	C		;FIND DIFFERANCE
	LD	C,A		;MAKE POINTER
	ADD	H		;MOVE BUFFER UP
	LD	H,A
.FILL:
	LD	A,0FFH		;FILL CHARACTERS
	LD	(HL),A
	CPI
	JP	V,.FILL		;CONTINUE TILL DONE
	LD	HL,BUFFER	;BACK TO START OF BUFFER
	POP	BC
	JR	.FULL1
.FULL:
	LD	C,A		;MOVE COUNT TO B
.FULL1:
	LD	A,(DCB)		;GET DRIVE NUMBER
	LD	B,A
	SC	50		;READ MULTIPLE SECTORS		CHANGE THIS
	JP	CMD		;DONE
NOFIND:
	LD	DE,MSG10
	SC	2		;DISPLAY 'CANT FIND FILE'	CHANGE THIS

;***************************************************************************
; READ PROM INTO BUFFER
;***************************************************************************

READ:
	LD	HL,BUFFER	;BUFFER START
	LD	BC,(SIZE)	;PRO5H	
	LD	A,CS		;SET PROGRAMMER TO READ MODE
	OUT	(CONT),A
	LD	A,RESET		;RESET PROM TO ADDR 0000
	CALL 	PULSE
.LOOP:
	IN	A,(DATA)	;READ PROM
	LD	(HL),A		;STORE
	CPI			;UPDATE POINTERS
	JP	PO,CMD		;DONE ?
	LD	A,CLOCK		;NEXT PROM ADDR
	CALL	PULSE		;
	JR	.LOOP		;LOOP TILL DONE

;***************************************************************************
; ALTER BUFFER MEMORY
;***************************************************************************

ALTER:
	CALL	ADDR		;GET ADDRESS TO ALTER
.IN1:
	PUSH	HL		;SAVE ADDR
	LD	DE,IBUF		;POINT TO START OF BUFFER
	LD	B,H		;CONVERT TO ASCII
	SC	16						;CHANGE THIS
	LD	B,L
	SC	16						;CHANGE THIS
	LD	A,20H		;BLANK CHAR
	LD	(DE),A
	INC	DE
	PUSH	DE		;SAVE DE
	LD	DE,BUFFER	;MAKE RELATIVE TO BUFFER
	ADD	HL,DE
	POP	DE		;RESTORE DE
	LD	B,(HL)		;GET DATA TO BE CHANGED
	SC	16
	LD	A,20H		;SPACE CHAR
	LD	(DE),A
	INC	DE
	LD	A,00H		;TERMINATOR
	LD	(DE),A
	LD	DE,IBUF		;BACK TO BEGINNING FOR OUTPUT
	SC	2
	PUSH	DE		;SAVE BUFFER LOC
	LD	A,20H		;BLANK 2 CHAR FOR INPUT
	LD	(DE),A
	INC	DE
	LD	(DE),A
	INC	DE
	LD	A,0DH		;CR
	LD	(DE),A
	POP	DE		;RESTORE BUFFER
	PUSH	DE		;CONTINUE TO SAVE
	LD	B,2		;LINE LENGTH
	CALL	LINEIN
	POP	DE		;BACK TO START OF INPUT
	JR	C,.EXIT		;DONE
	LD	A,C		;SEE IF NO INPUT
	OR	A
	JR	Z,.NONE
	PUSH	HL		;SAVE WHILE DOING CALC
	SC	14		;CONVERT TO BINARY		CHANGE THIS
	JR	C,.OVER		;OVERFLOW
	LD	B,L		;
	POP	HL		;GET BUFFER ADDR BACK
	LD	(HL),B		;STORE NEW VALUE
	POP	HL		;GET ADDR BACK
	INC	HL		;NEXT LOCATION
	JR	IN1		;NEXT INPUT
.OVER:
	POP	HL		;POP BUFFER ADDR OFF
	POP	HL		;GET ADDR BACK
	JP	.IN1		;TRY AGAIN
.NONE:
	POP	HL		;GET ADDR BACK
	INC	HL
	JP	.IN1		;GET NEXT CHAR
.EXIT:
	POP	HL		;EMPTY STACK
	JP	CMD		;NEXT COMMAND

;***************************************************************************
; DUMP BUFFER MEMORY
;***************************************************************************

DUMP:
	CALL	ADDR		;GET ADDR TO DUMP
.DUMP1:
	PUSH	HL		;SAVE ADDR
	LD	DE,IBUF		;DISPLAY ADDR
	LD	B,H
	SC	16						;CHANGE THIS
	LD	B,L
	SC	16						;CHANGE THIS
	LD	A,20H		;BLANK AS SPACER
	LD	(DE),A
	INC	DE
	PUSH	DE		;SAVE WHILE DOING CALC
	LD	DE,BUFFER	;MAKE ADDR REL BUFFER
	ADD	HL,DE
	POP	DE		;RESTORE IBUF POINTER
	LD	BC,16		;NUMBER OF CHARACTERS TO DUMP
	PUSH	BC		;SAVE IT
.LOOP:
	LD	B,(HL)		;GET BYTE
	SC	16		;CONVERT TO HEX ASCII IN BUFFER
	POP	BC
	CPI			;UPDATE POINTERS
	JP	PO,.DONE
	PUSH	BC		;SAVE BC
	LD	A,2CH		;COMMA BETWEEN BYTES
	LD	(DE),A
	INC	DE
	JR	.LOOP
.DONE:
	LD	A,00H		;TERMINATE STRING
	LD	(DE),A
	LD	DE,IBUF		;BACK TO START FOR DISPLAY
	SC	2		;DISPLAY			CHANGE THIS
	POP	HL		;GET ADDR BACK
	LD	DE,16		;UPDATE ADDR
	ADD	HL,DE
	LD	DE,IBUF		;READY FOR NEXT COMMAND
	LD	B,1		;ONE CHAR ONLY
	LD	A,20H		;CLEAR DISPLAY
	LD	(DE),A		;
	CALL	LINEIN		;GET COMMAND
	JP	C,CMD		;EXIT
	JP	.DUMP1		;DO NEXT 16 CHAR
	PUSH	BC
	CPI			;UPDATE POINTERS
	JP	CMD		;NOT IMPLEMENTED 

;***************************************************************************
; SUBROUTINES
;***************************************************************************

ADDR:	LD	HL,IBUF		;INPUT BUFFER ADDRESS
	LD	BC,4		;LENGTH
	CALL	CLEAR		;CLEAR BUFFER
	LD	(HL),00		;TERMINATOR
	LD	DE,MSG16	;REQUEST ADDRESS
	SC	2						;CHANGE THIS
	LD	B,4		;4 HEX DIGITS
	LD	DE,IBUF
	CALL	LINEIN		;INPUT ADDRESS
	LD	DE,IBUF
	SC	14		;CONVERT TO BINARY IN HL	CHANGE THIS
	JR	C,ADDR		;OVERFLOW
	RET			;DONE
CLEAR:
	LD	A,20H		;BLANKS
.BLANK:
	LD	(HL),A		;STORE
	CPI			;UPDATE POINTERS
	JP	PE,.BLANK	;LOOP TILL DONE
	RET
PULSE:
	OR	SET		;SET BIT
	OUT	(CONT),A	;OUTPUT PULSE
	AND	CLR		;CLEAR PULSE
	OUT	(CONT),A	;RESET PULSE
	RET


;***************************************************************************
; VARIABLE STORAGE
;***************************************************************************

MSG1:		DC      OCH,'EP -2A PROM PROGRAMMER',0AH
		DC	'1. 2708',0AH
		DC	'2. 2758',0AH
		DC	'3. 2716',0AH
		DC	'4. 2732'
		DC	'5. TMS 2708',0AH
		DC	'6. TMS 2716',0AH
		DC	'7. TMS 2732',0AH
		DC	0AH
		DC	'ENTER PROM TYPE - ',00H
MSG2:		DC	0CH,'PROM TYPE ',00H
;
; EACH LINE OF MSGE MUST BE 8 CHAR PLUS CR 
;
MSG3:		DC	'2708    ',0DH
		DC	'2758    ',0DH
		DC	'2716    ',0DH
		DC	'2732    ',0DH
		DC	'TMS 2708',0DH
		DC	'TMS 2716',0DH
		DC	'TMS 2732',0DH
MSG4:		DC	0AH,'E. ERASE CHECK',0AH
		DC	'P. PROGRAM PROM',0AH
		DC	'V. VERIFY PROM',0AH
		DC	'F. DEFINE FILE TO BE USED FOR LOADING',0AH
		DC	'L. LOAD DISK FILE INTO BUFFER',0AH
		DC	'R. READ PROM CONTENTS INTO BUFFER',0AH
		DC	'A. ALTER BUFFER (HEX MUST REMAIN IN ORDER
		DC	'D. DUMP BUFFER (HEX) ',0AH
		DC	'T. CHANGE PROM TYPE ',0DH
MSG5:		DC	0AH,'COMMAND : ',00H
MSG6:		DC	'FILE NAME: ',00H
MSG7:		DC	'FILE TYPE: ',00H
MSG8:		DC	'DRIVE    : ',00H
MSG9:		DC	'ADDRESS- HIGH ORDER BYTE: ',00H
MSG10:		DC	'CANT FIND FILE ',0DH
MSG11:		DC	'FILE NOT ABSOLUTE ',0DH
MSG12:		DC	'FILE HAS NOT BEEN DEFINED (USE "F") ',0DH
MSG13:		DC	'PROM LOAD ADDRESS ',00H
MSG14:		DC	' IS BELOW PROGRAM START ADDRESS ',00H
MSG15:		DC	'PROM START ADDRESS IS ABOVE PROGRAM SPACE',0DH
MSG16:		DC	'ADDRESS: ',00H

DCB:    	DS	17	;DIRECTORY CONTROL BLOCK
WORK:		DS	256	;WORK AREA FOR DIRECTORY LOOKUP
IBUF:		DS	60	;INPUT/OUTPUT BUFFER

				; FILE VARIABLES MUST REMAIN IN ORDER

LOADADDR:	DS	3	;PROM BASE ADDRESS + TERMINATOR CHAR
FILEADDR:	DC	0	;FILE LOAD ADDRESS MSB
FILESEC:	DC	00,0	;UPDATE POINTERS
LOC		DS	2	;CURRENT LOCATION IN BUFFER
PROM		DS	1	;PROM TYPE
SIZE:		DC	00,00	;SIZE OF PROM
LOOPCNT:	DC	00	;LOOP COUNT
DELCNT:		DC	00	;DELAY COUNT - MUST FOLLOW LOOPCOUNT

PARAM:				;PARAMETER TABLE- SIZE IN 256 BYTE BLOCKS
				;		  NUMBER OF PROGRAMMING LOOPS
				;		  DELAY TIME IN .75MS INTERVAL 
		DC	4,133,1	;2708
		DC	4,1,75	;2758
		DC	8,1,75	;2716
		DC	16,1,75	;2732
		DC	4,133,1	;TMS2708
		DC	8,133,1	;TMS2716
		DC	16,1,75	;TMS3732
ERCHK:		DC	0FFH	;ERASED CHARACTER
BUFFER:		DS	4096	;4K BUFFER


